<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-product-edit" th:object="${product}">
            <input id="id" name="id" th:field="*{id}"  type="hidden">
            <div class="form-group">	
                <label class="col-sm-3 control-label">厂商编号：</label>
                <div class="col-sm-8">
                    <!-- <input id="gardenNo" name="gardenNo" th:field="*{gardenNo}" class="form-control"  readonly="true" type="text"> -->
                    <select id="gardenNo" name="gardenNo"  class="form-control m-b" th:with="type=${@garden.getGarden()}">
	                    <option th:each="garden : ${type}" th:text="${garden.gardenName+garden.teaGardenNo}" th:value="${garden.teaGardenNo}" th:field="*{gardenNo}"></option>
	                </select>
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">产品类型：</label>
                <div class="col-sm-8">             
                 
                    <select id="productType" class="form-control m-b" th:with="type=${@dict.getType('gh_product_type')}">
	                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{productType}"></option>
	                </select>
                </div>
            </div>
            
            	
            
            <div class="form-group">	
                <label class="col-sm-3 control-label">产品唯一识别码：</label>
                <div class="col-sm-8">
                    <input id="productCode" name="productCode" th:field="*{productCode}" class="form-control" type="text">
                </div>
            </div>
             <div class="form-group">	
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">         
                        <select id="status" class="form-control m-b" th:with="type=${@dict.getType('gh_product_status')}" disabled="disabled">
	                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{status}"></option>
	                </select>
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">更新时间：</label>
                <div class="col-sm-8">
                    <input id="updateTime" name="updateTime" th:field="*{updateTime}" class="form-control" readonly="true" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input id="remark" name="remark" th:field="*{remark}" class="form-control" type="text">
                </div>
            </div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "module/product"
		$("#form-product-edit").validate({
			rules:{
				xxxx:{
					required:true,
					minlength: 6,
        			maxlength: 6
				},
				productCode:{
					required:true,
					minlength: 20,
        			maxlength: 20
				}
				
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	edit();
	        }
	    }
		
		 function edit() {
			    var id = $("input[name='id']").val();
	        	var gardenNo = $("#gardenNo option:selected").val();
	        	var productType = $("#productType option:selected").val();
	        	var status = $("#status option:selected").val();
	        	var productCode = $("input[name='productCode']").val();
	        	var remark = $("input[name='remark']").val();
	     
	        	$.ajax({
	        		cache : true,
	        		type : "POST",
	        		url : prefix + "/edit",
	        		data : {
	        			"id": id,
	        			"gardenNo": gardenNo,
	        			"productType": productType,
	        			"status": status,
	        			"productCode": productCode,	        			
	        			"remark": remark
	        		},
	        		async : false,
	        		error : function(request) {
	        			$.modal.alertError("系统错误");
	        		},
	        		success : function(data) {
	        			$.operate.saveSuccess(data);
	        		}
	        	});
	        }
	</script>
</body>
</html>
